/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import java.util.LinkedList;
import javax.servlet.*;
import javax.servlet.http.*;
import models.User;
import models.Course;
import models.Module;
import models.Announcement;
/**
 *
 * @author Notez
 */
public class AnnouncementListController extends HttpServlet {
    


    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
            Dbmanager dbManager = new Dbmanager();
            dbManager.openConnection();
            QueryManager queryManager = new QueryManager(dbManager);
            int courseID;
            Course course;
            LinkedList<Announcement> announcements = new LinkedList<Announcement>();
            courseID = Integer.parseInt(request.getParameter("id"));
            announcements = queryManager.getAllAnnouncements(courseID);
            course = queryManager.getCoursbyid(courseID);
            request.setAttribute("course", course);
            request.setAttribute("announcementsUitSessie", announcements);
            request.setAttribute("courseID", courseID);
            dbManager.closeConnection();

            RequestDispatcher dispatcher = request.getRequestDispatcher("/announcements.jsp");
            dispatcher.forward(request, response);
        
    }
    
}